import { PrismaConst } from '@/common/constant/prisma.constant';

// 根据字段获取对象中有的属性
export function pickEquals<T extends object>(obj: T, keys: string[]): any {
    const result: any = {};

    keys.forEach(key => {
        if (key in obj && obj[key] !== undefined && obj[key] !== null) {
            result[key as keyof T] = obj[key as keyof T];
        }
    });

    return result;

}

// 根据字段获取对象中有的属性
export function pickLike<T extends object>(obj: T, keys: string[]): any {
    const result: any = {};

    keys.forEach(key => {
        if (key in obj && obj[key] !== undefined && obj[key] !== null) {
            result[key as keyof T] = {
                contains: obj[key as keyof T]
            };
        }
    });

    return result;

}